<?php
include "../lib/mysql.lib";

abstract  class Entity
{
	public $mlEntityID = -1; // Index of entity
	public $mstrTableName = ""; // table that store the Entity
	public $mstrEntityIDName = ""; // the Entity Index field name

	public $mConn;				//MySql Connection	

	public function __construct($conn)
	{
		if ($conn != null && $conn instanceof MySQL) {
			$this->mConn = $conn;
		}
	}

	public function __construct($lEntityID, $conn)
	{
		$this->mlEntityID = $lEntityID;
		$this->mConn = $conn;
	}

	// All Abtract Function that all real entity must be declare
	public abstract function AddNew();
	public abstract function Update();

	// All Virtual Function that all real entity can define
	public function GetObjectData()
	{
		return false;
	}

	public function GetObjectList($searchCriteria)
	{
		return null;
	}
	public function GetObjectList($strStoreProcName, $paraList)
	{
		return null;
	}
	// this delete function can be use for all most entity, any special can override this
	public function Delete()
	{
		$strSQL = "Delete from " + mstrTableName + " where " + mstrEntityIDName + " = " + mlEntityID;
		return mConn.ExecuteNoneQuery(strSQL);
	}

	public function Dispose()
	{
		mConn.Conn.Close();
	}
}
?>